<template>
  <div>
    <a-row> 
      <a-col :span="12"  class='mb20'>
          <a-input  placeholder="请输入名称"  style='width:200px'  v-model='search.keyWord'/>
          <a-button type="primary" @click='pageInit()'>搜索</a-button>
      </a-col>
    </a-row>
   
    <a-table :columns="columns" :dataSource="data"  :pagination="pagination"   @change="handleTableChange"> 
      <span slot="supOrBuyer"  slot-scope="text, record">{{text | customType}}</span> 
      <span slot="status"  slot-scope="text, record">{{text | audit_status}}</span> 
      <span slot="createTime"  slot-scope="text, record">{{text | formatDate}}</span> 
       
      <span slot="action" slot-scope="text, record"> 
        <span   @click='editUser(record.code)'   class='color-blue cursor'>编辑</span>
        <a-divider type="vertical" /> 
        <a-popconfirm title="确认删除当前数据？" @confirm="confirmDel(record.code)"   okText="确认" cancelText="取消">
            <a href="javascript:;"  class='color-red '>删除</a>
        </a-popconfirm>
      </span>
    </a-table>
    <!-- user-modal -->
    <addUser  ref='userModal' :visible='showAddUser' :depatrDisabled='true'  v-on:handleCancel='showAddUser=false'  v-on:handleOk='handleOkUser()'></addUser>
  </div>
</template>

<script>
import  addUser  from  '@/components/system/userlist/addUser'
const  columns  = [
        {
        title: '登录用户名',
        dataIndex: 'loginName',
        key:'loginName'
      }, {
        title: '联系电话',
        dataIndex: 'mobile', 
      }, {
        title: '创建注册时间',
        dataIndex: 'createTime', 
        scopedSlots: { customRender : 'createTime' }
      },{
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' },
      },]
import { listUser_of_olivia } from '@/api/olivia'
import { delUser } from '@/api/system/index'
export default {
  name: 'RecustomerFromOlivia',
  data () {
    return {
        columns,
        data:[ 
        ],
        search:{
          keyWord:'',
          pageSize:10,
          pageNo:1
        },
        pagination:{
          total:0,
          pageSize: 10,//每页中显示10条数据
          showSizeChanger: true,

          pageSizeOptions: ["10", "20"],//每页中显示的数据
          showTotal: total => `共有 ${total} 条数据`,  //分页中显示总的数据
        },  
        showAddUser:false,/*用户编辑 - 新增modal*/
    }
  },
  created(){
     this.pageInit()
  },
  methods:{
    pageInit(){ 
        listUser_of_olivia(this.search).then((res)=>{
            if(res.data.flag == true){
              this.data = res.data.dataList
              this.pagination.total = res.data.totalRs
            }
         })
    },
    handleTableChange (pagination, filters, sorter) {
        // console.log(pagination);
        this.search.pageNo = pagination.current
        this.search.pageSize =pagination.pageSize
        this.pageInit()
    },
     editUser(code){
        this.$refs.userModal.$emit('editDialog',code)
        this.showAddUser = true
    },
    handleOkUser(){ 
          this.showAddUser = false
          this.pageInit() 
    },
    confirmDel(code){
        delUser(code).then((res)=>{
            this.$message.info(res.data.msg)
            this.pageInit()
        })
    },
  },
  computed:{
    
  },
  components:{ 
    addUser
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
